package com.lyfx.ly.web;

import com.lyfx.ly.service.ClassCategoryService;
import com.lyfx.ly.vo.CatelogVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author lsy
 * @create 2020-07-27-17:33
 */
@Controller
public class IndexController {
    @Autowired
    ClassCategoryService categoryService;

    @RequestMapping({"/index","/","/index.html"})
    public String index(Model model) {
        //查出所有的分类
        List<CatelogVo> categoryEntities = categoryService.getLevelCategorys();
        model.addAttribute("categorys",categoryEntities);
        return "index";
    }

    //----测试用，
    @RequestMapping("/cat")
    @ResponseBody
    public List<CatelogVo> getCat(){
        List<CatelogVo> categoryEntities = categoryService.getLevelCategorys();
        return categoryEntities;
    }
}
